@extends('layout/index')

@section('main')
    <div class="mws-panel grid_8">
        <div class="mws-panel-header">
            <span>添加商品评论</span>
        </div>
        <div class="mws-panel-body no-padding">
            <form class="mws-form" action="/Admin/comment/insert" method="post" enctype="multipart/form-data">
                <div class="mws-form-inline">

                     <div class="mws-form-row">
                        <label class="mws-form-label">管理员</label>
                        <div class="mws-form-item">
                            <select class="small" name="uid">
                            @foreach($row as $k => $v)
                                <option value="{{ $v->id }}">{{ $v->username }}</option>
                            @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="mws-form-row">
                        <label class="mws-form-label">商品分类</label>
                        <div class="mws-form-item">
                            <select class="small" name="tid" id="sel">
                            @foreach($res as $k => $v)
                                <option id="tid" value="{{ $v->id }}">{{ $v->typename }}</option>
                            @endforeach
                            </select>
                        </div>
                    </div>

                      <div class="mws-form-row">
                        <label class="mws-form-label">商品名称</label>
                         <div class="mws-form-item">
                            <select class="small" name="gid" id="typeid">
                       
                           
                            </select>
                        </div>
                    </div>

                    <div class="mws-form-row">
                        <label class="mws-form-label">商品图片</label>
                        <div class="mws-form-item">
                           <img id="img" src="" alt=""  style="width:100px">
                        </div>
                    </div>

                    <div class="mws-form-row">
                        <label class="mws-form-label">评价内容</label>
                        <div class="mws-form-item">
                            <textarea rows="" cols="" class="small" name="content"></textarea>
                        </div>
                    </div>

                </div>
                {{ csrf_field() }}
                <div class="mws-button-row">
                    <input value="添加" class="btn btn-danger" type="submit">
                    <input value="重置" class="btn " type="reset">
                </div>
            </form>
        </div>
    </div>


@endsection


@section('js')


<script type="text/javascript">

//获取分类列表的值
 $("#sel").change(function(){

      var res = $(this).val();

     //发送ajax
     $.get('/Admin/comment/ajax',{id:res},function(data){

            var str = '';
            for(var i=0;i<data.length;i++) {
                str += "<option value="+data[i].id+">"+data[i].goodsname+"</option>";

                $("#typeid").html(str);
             }

          },"json")
    })


 //获取商品的值
 $("#typeid").change(function(){

    var row = $(this).val();

    //发送ajax
    $.get('/Admin/comment/ajaxajax',{id:row},function(data){
       
        $("#img").attr("src",data);

    })

 })

</script>
@endsection

    